#include "parse.h"

void process_pipelined_request(int client_sock, char *recv_buf);
void handle_request(int client_sock, ssize_t readret, char* recv_buf);

void response_echo(int client_sock, char* recv_buf);

int response_get(int client_sock, Request* request);
int response_head(int client_sock, Request* request);
int response_post(int client_sock, Request* request);

void response400(int client_sock);
void response404(int client_sock, char *response);
void response408(int client_sock);
void response501(int client_sock);
void response505(int client_sock);

int is_dir(const char *path);
void get_extension(const char *path, char *result);
void get_mime_type(const char *mime, char *type);
void get_curr_time(char *time_buf, size_t buf_size);
void get_flmodified(const char*path, char *last_mod_time, size_t buf_size);
size_t get_file_len(const char* fullpath);
void get_header_value(Request *request, const char *hname, char *hvalue);

int send_nbytes(int sock, const void *p, int nbytes);
void Send_nbytes(int sock, const void *ptr, int nbytes);
int send_file_to_client(int client_sock, char* full_path);

